import axios from "axios";

const API_URL='/api'

//post/put/delete请求  发送的是json数据 后端获取 @RequestBody
const login = async(data)=>{

    const response = await axios.post(API_URL+'/user/login',data)
    return response.data
}

const uploadFile = async(data)=>{
    const response = await axios.post(API_URL+'/file/upload',data,{
        headers:{
            "Authorization":"Bearer "+localStorage.getItem('token'),
            "Content-Type": "multipart/form-data"
        }
    })
    return response.data
}

const register = async(data)=>{
    const response = await axios.post(API_URL+'/user/add',data)
    return response.data
}

export default{
    login,
    uploadFile,
    register
}